package errcode

const (
	RecodeOk          = "200"
	RecodeDbErr       = "4001"
	RecodeNodata      = "4002"
	RecodeDataExist   = "4003"
	RecodeDataErr     = "4004"
	RecodeSessionErr  = "4101"
	RecodeLoginErr    = "4102"
	RecodeParamErr    = "4103"
	RecodeUserErr     = "4104"
	RecodeRoleErr     = "4105"
	RecodePwdErr      = "4106"
	RecodeReqErr      = "4201"
	RecodeIpErr       = "4202"
	RecodeThirdErr    = "4301"
	RecodeIoErr       = "4302"
	RecodeServerErr   = "4500"
	RecodeUnknowErr   = "4501"
	RecodeDataMissErr = "4502"
)

var recodeText = map[string]string{
	RecodeOk:          "成功",
	RecodeDbErr:       "数据库查询错误",
	RecodeNodata:      "无数据",
	RecodeDataExist:   "数据已存在",
	RecodeDataErr:     "数据错误",
	RecodeSessionErr:  "用户未登录",
	RecodeLoginErr:    "用户登录失败",
	RecodeParamErr:    "请求参数错误",
	RecodeUserErr:     "用户不存在或未激活",
	RecodeRoleErr:     "登录身份错误",
	RecodePwdErr:      "密码错误",
	RecodeReqErr:      "非法请求或请求次数受限",
	RecodeIpErr:       "IP受限",
	RecodeThirdErr:    "第三方系统错误",
	RecodeIoErr:       "文件读写错误",
	RecodeServerErr:   "内部错误",
	RecodeUnknowErr:   "未知错误",
	RecodeDataMissErr: "数据存在缺失(请检查cve编号、组件、版本号等)",
}

//RecodeText get resp string by code
func RecodeText(code string) string {
	str, ok := recodeText[code]
	if ok {
		return str
	}
	return RecodeText(RecodeUnknowErr)
}
